<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		
		<button onclick="foo1()">弹出警告框</button>
		<button onclick="foo2()">弹出询问框</button>
		<button onclick="foo3()">弹出输入框</button>
		<button onclick="add()">随机计算</button>
		
		<script>
			
			function foo1(){
				
				// 1.警告框 window可以省略不写
				alert("Hello!");	
							
			}

			function foo2(){
				
				if(confirm("确认删除？")){
					alert("Done");
				}else{
					alert("Cancel");
				}
							
			}

			function foo3(){
				
				if(prompt("1+2=？") == 3){
					alert("Right");
				}else{
					alert("Wrong");
				}
							
			}
			
			function add(){
				
				var a = parseInt(Math.random() * 100);
				var b = parseInt(Math.random() * 100);
				if(prompt(a + "+" + b + "=") == a+b){
					alert("Right");
				}else{
					alert("Wrong");
				}				
				
			}
			
			
		</script>
		
		
	</body>
</html>